package com.example.anquan.repository;

import com.example.anquan.guanli.Article;
import com.example.anquan.guanli.Comment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface CommentRepository extends JpaRepository<Comment, Integer> {
    public List<Comment> findByArticleId(Integer id);
    @Transactional
    @Modifying
    public void deleteByArticle(Article article);
    // 根据id删除对应评论
    @Transactional
    @Modifying
    @Query("DELETE FROM Comment  c WHERE c.id= ?1")
    public int deleteDiscuss(Integer id);
}

